home *** CD-ROM | disk | FTP | other *** search
/ Guide To Cracking 2002 / Guide_to_Cracking_2002.iso / Tutorials / Nag and Time Trial / nag / ns14.txt < prev    next >
Encoding:
Text File  |  1999-07-11  |  15.1 KB  |  262 lines

  1. CRACKING TUTORIAL RELEASE 1
  2.  
  3. DATE: 13/2/98
  4. AUTHOR: Quantico  Mexelite'98
  5. EDITOR: Full screen notepad with wordrap on
  6. LEVEL: Intermediate
  7.  
  8. TARGET PROGRAM:  Directory toolkit version 2.63
  9. WHERE?:  www.funduc.com
  10. PROTECTION(s): NAG, 21 day trial, *-Unregistered* in title bar.
  11. SOLUTION:  A GOOD PATCH JOB :)
  12.  
  13. TOOLS: Good old softice (i used 3.00), w32dasm 8.9, hex editor (hex workshop) and a patch               generator like patchit by Qapla or rtd_patch by Mr. Wicked, or write your own. 
  14.  
  15. NOTES:  Phew, I now have most of my (minor) exams over and only a few next week so I have time to         fix this tutorial up a bit.  I hope someone learns from this, that's all I want :)
  16.  
  17. PATCHES: patches in pascal, asm, c++ and C have been included in this zip for you to study and          learn from.  They have been created from a patch generator (rtd_patch & patchit) as I          have not yet finished my own patcher source in pascal.  The .com file is the complied          (and slightly modified asm code.)
  18.  
  19. =================================================================================================
  20.  
  21. Right, lets get started.  
  22.  
  23.    You should know by now that you never try to crack something without getting a 'feel' of it first.  So run it and see what it does.  OK, we notice a nasty nag on startup and if we click OK then we go on into the program.  In the title bar, youll see a -Unregistered notice.  If you hunt around the menus and look in the help file, you will find that there is no way to turn this into a full version, ie. 'unlock' it and you have to pay $$$ and get it sent to you.  You should also find that the program expires in 21 days.  Lets change all that, shall we?
  24.  
  25. OK, the first thing, and the most annoying thing to crack is the nag.  There are a few ways that a programmer can create a nag but most involve the following calls:
  26.  
  27. 1) messagebox(a)
  28. 2) dialogboxparam(a)
  29. 3) createdialogindirectparam(a)
  30. 4) dialogboxindirectparam(a)
  31.  
  32. The nag does not look like either of the first two styles which are more plain and simple so lets bpx on the 3rd one and the 4th one, createdialogindirectparama and dialogboxindirectparama, i use the 'a' at the end 'cos its a 32bit prog.
  33.  
  34. :bpx createdialogindirectparama
  35. :bpx dialogboxindirectparama
  36.  
  37. and then run directory toolkit.
  38.  
  39. Softice will break at createdialogindirectparama
  40.  
  41. Each time softice pops, ctrl-d out again to see when the nag is made.
  42. Softice will pop 3 times before the nag is made so it is the 3rd call to createdialogindirectparama that makes the nag so lets run the prog again and look at the 3rd call.  Stop on the 3rd break and F12 to return to the function that called it, we are now back in the directory toolkit code;
  43.  
  44. :00455B15 E867FCFFFF              call 00455781
  45. :00455B1A 33DB                    xor ebx, ebx  <===== we land here
  46.  
  47. (SIDE NOTE: If you don't have the opcodes to the left of the commands, type 'code on' in softice)
  48.  
  49. press F4 too see if the nag is made yet but it is not and F4 to return again to softice, so it must be made a little further on in the code because it has just started to process it. Keep stepping with F10....
  50.  
  51. :00455B1C 3BC3                    cmp eax, ebx
  52. :00455B1E 7457                    jz 00455B77   <===== no jump
  53. :00455B20 F6462410                test [esi+24], 10
  54. :00455B24 741C                    jz 00455B42   <===== no jump
  55. :00455B26 6A04                    push 00000004
  56. :00455B28 8BCE                    mov ecx, esi
  57. :00455B2A 5B                      pop ebx
  58. :00455B2B E8E6030000              call 00455F16
  59. :00455B30 F6C401                  test ah, 01
  60. :00455B33 7403                    jz 00455B38   <===== jump here =======
  61. :00455B35 6A05                    push 00000005                         |
  62. :00455B37 5B                      pop ebx                               |
  63.                                                                         |
  64. * Referenced by a (U)nconditional or (C)onditional Jump at Address:     |
  65. |:00455B33(C)                                                           |
  66. |                                                                       |
  67. :00455B38 53                      push ebx     <========================
  68. :00455B39 8BCE                    mov ecx, esi
  69. :00455B3B E8FBF5FFFF              call 0045513B ***
  70. :00455B40 33DB                    xor ebx, ebx
  71.  
  72. *** this call actually finishes making the nag and if you trace inside it, you will see a !UPDATEWINDOW call.  So we can now presume that this whole section of code is all involved in making the nag and so it must be called from somewhere else.  Run the program again, and on the 3rd break, F12 twice (you will have to press the OK button on the nag) and you will see the following code:
  73.  
  74. :0040E334 E821770400              call 00455A5A
  75. :0040E339 8D8C2434010000          lea ecx, dword ptr [esp+00000134]  <===== we land here
  76. :0040E340 C784247801000003000000  mov dword ptr [esp+00000178], 00000003
  77. :0040E34B E818280500              call 00460B68 
  78.  
  79. it is the call at 0040E334 that constructs the nag but if you had studied the program correctly, you would have noticed that the nag and the 'about' dialog are identical.  We could take out the above call but it would leave us with no 'about' dialog (believe me, i tried it!) so F12 again to step back another section and you land here:
  80.  
  81. :0040D32D 8986A8070000            mov dword ptr [esi+000007A8], eax
  82. :0040D333 E8C80F0000              call 0040E300
  83. :0040D338 8D4C2430                lea ecx, dword ptr [esp+30]  <====== you land here
  84. :0040D33C 896C2430                mov dword ptr [esp+30], ebp
  85. :0040D340 896C2434                mov dword ptr [esp+34], ebp
  86. :0040D344 E8B7A20200              call 00437600
  87.  
  88. Ok, now we've found the call that makes the nag, lets bpx on it and see if we can patch it.
  89.  
  90. :bd * (disable other breakpoints)
  91. :bpx 0040D333 (or whatever yours was)
  92.  
  93. and run the program again.  You should stop at the line with the nag call on it.  Lets try nopping it, (i only nop it when testing, i use a better method when permanently patching)
  94. the call is 5 bytes long so lets use 5 nops
  95.  
  96. :a
  97. :nop
  98. :nop
  99. :nop
  100. :nop
  101. :nop
  102.  
  103. That looks horrible i know.  Now ctrl-d and see if it works. DO you see any nag? I dont :)
  104. Ok, one part done, lets patch that.  Open up a hex editor and load that file, search for
  105. 8986A8070000E8C80F0000 (the line b4 the call and the call opcodes) and start patching at the E8 byte (cos it is the start of the nag_you call) changing 
  106.  
  107. E8C80F0000   call 0040E300       
  108.  
  109. to
  110.  
  111. 40   inc eax
  112. 48   dec eax
  113. 90   nop
  114. 40   inc eax
  115. 48   dec eax
  116.  
  117. save it as a different file (to keep the original intact) and test it.  There should be no nag now.  Well done.  
  118.  
  119. The next part of the program, and a lot easier than the nag, is the 21 day trial part.  Set the PC clock 30 days ahead and then run the program.  If you are running the original copy, the nag should pop up and if you click OK, a messagebox will tell you that you are past the trial period.  Note what that messagebox says;
  120.  
  121. "The evaluation period expired.
  122.  Do you want to see the ordering information?"
  123.  
  124. If we click no, we are thrown out of the program and if yes then we are shown the helpfile.  Either way, the program doesn't run anymore.
  125. Im gonna use wdasm for this approach rather than softice 'cos its easier.  Wdasm the file and then look in the string reference section for the messagebox text and then double click on it to get to that section.
  126.  
  127. :0040D33C 896C2430                mov dword ptr [esp+30], ebp
  128. :0040D340 896C2434                mov dword ptr [esp+34], ebp
  129. :0040D344 E8B7A20200              call 00437600
  130. :0040D349 85C0                    test eax, eax
  131. :0040D34B 743A                    je 0040D387  <======== important
  132.  
  133. * Possible Reference to String Resource ID=00002: "Directory Toolkit Windows 95/NT Application"
  134.                                   |
  135. :0040D34D 6A02                    push 00000002
  136. :0040D34F E88CC60100              call 004299E0
  137. :0040D354 83C404                  add esp, 00000004
  138. :0040D357 8986A8070000            mov dword ptr [esi+000007A8], eax
  139. :0040D35D 6AFF                    push FFFFFFFF
  140. :0040D35F 6A04                    push 00000004
  141.  
  142. * Possible Reference to String Resource ID=02106: "The evaluation period expired.
  143. Do you want to                                                    see the Ordering Information?"
  144.                                   |
  145. :0040D361 683A080000              push 0000083A
  146. :0040D366 E8C6ED0400              call 0045C131
  147. :0040D36B 83F806                  cmp eax, 00000006
  148. :0040D36E 750E                    jne 0040D37E
  149. :0040D370 8B16                    mov edx, dword ptr [esi]
  150.  
  151.  
  152. Note that the jump at 0040D34B jumps PAST the 'expired' part.
  153. This is obviously the section that decides which path the program should take as inside the call at 0040d344 there is various date gathering information and bad_guy jumps accordingly.  (Sorry for the long code snippits)
  154.  
  155. * Referenced by a CALL at Address:
  156. |:0040D344   
  157. |
  158. =====cut a bit to save space=====================================================================
  159.  
  160. :00437628 8D4C2410                lea ecx, dword ptr [esp+10]
  161. :0043762C E8F49A0100              call 00451125   <===========go get some date info
  162. :00437631 8B4014                  mov eax, dword ptr [eax+14] <=== put last 2 figures of year                                                                       into eax
  163. :00437634 056C070000              add eax, 0000076C <==== add 1900 to eax (1900+year)
  164. :00437639 3DCC070000              cmp eax, 000007CC <==== compare with 1996
  165. :0043763E 752C                    jne 0043766C      <==== jump not equal ???
  166. :00437640 53                      push ebx
  167. :00437641 8D4C2410                lea ecx, dword ptr [esp+10]
  168. :00437645 E8DB9A0100              call 00451125
  169. :0043764A 8B4010                  mov eax, dword ptr [eax+10] <=== put month minus 1 into eax
  170. :0043764D 40                      inc eax    <========= add 1 to eax.....eax=month number
  171. :0043764E 83F807                  cmp eax, 00000007 <=== compare with 7  (July)
  172. :00437651 7519                    jne 0043766C  <======== bad_dude
  173. :00437653 53                      push ebx
  174. :00437654 8D4C2410                lea ecx, dword ptr [esp+10]
  175. :00437658 E8C89A0100              call 00451125
  176. :0043765D 83780C01                cmp dword ptr [eax+0C], 00000001
  177. :00437661 7509                    jne 0043766C  <====== bad_dude
  178. :00437663 33C0                    xor eax, eax  <====== set good flag (0)
  179. :00437665 5F                      pop edi
  180. :00437666 5E                      pop esi
  181. :00437667 5B                      pop ebx
  182. :00437668 83C40C                  add esp, 0000000C  <=== stack correction
  183. :0043766B C3                      ret
  184.  
  185. If someone can explain a little more to me about this 'strange' call, i would appreciate it because it does not seem to make sense, like jumping if the year is not = to 1996!!!
  186.  
  187. The calls to 00451125 get date information but I don't know what the third call to it does, eax is a really large number and the program always takes the jump there.  Someone please tell me :)
  188.  
  189. Anyway, there are 3 jumps to 0043766C which mucks about and generally sets the bad flag before returning to do a test eax,eax.  If none of these jumps are taken, eax gets zeroed so we can either take out all the jumps in the call and let the zero flag get set,  we can patch the jump after the test eax,eax or we could follow the bad_guy jumps and change the mov eax, 1 instruction to a mov eax, 0.  Instead of nopping (for instance) the jumps, we could change them to 'xor eax,eax' which would set the good flag and take out the jumps.  I haven't tested that and its just an idea so i'll leave it to you. The same with the flag faking.  What im going to do is patch the jump after the RET.
  190.  
  191. Remember this?
  192.  
  193. :0040D344 E8B7A20200              call 00437600
  194. :0040D349 85C0                    test eax, eax <======== we come back here
  195. :0040D34B 743A                    je 0040D387   <======== important
  196.  
  197. * Possible Reference to String Resource ID=00002: "Directory Toolkit Windows 95/NT Application"
  198.                                   |
  199. :0040D34D 6A02                    push 00000002
  200.  
  201.  
  202. We want the jump at 0040d34b to always be taken so the proggie never expires.  Lets change;
  203.  
  204. 85C0   test eax,eax
  205. 743A   je 0040d387        (jump if still in trial)
  206.  
  207. to the following;
  208.  
  209. 85C0   test eax,eax
  210. EB3A   jmp 0040d387       (always jump to good_guy bit)
  211.  
  212. And thats the date done.  You could also change the call to a xor eax, eax but I haven't tried any other possibilities, I'll just explain a little and leave them for you as an exercise :)
  213.  
  214. You would have to do the following.
  215.  
  216. :0040D344 E8B7A20200              call 00437600
  217. :0040D349 85C0                    test eax, eax <======== we come back here
  218. :0040D34B 743A                    je 0040D387   <======== important
  219.  
  220. CHANGE THAT TO
  221.  
  222. :0040D344 40                      inc eax
  223. :0040D345 90                      nop
  224. :0040D346 48                      dec eax
  225. :0040D347 33C0                    xor eax, eax
  226. :0040D349 85C0                    test eax, eax
  227. :0040D34B 743A                    je 0040D387
  228.  
  229. (SIDE NOTE: you could also crack the time limit by doing a 'bpx messageboxa' and F12 about 3-4 times...again you can try it..I'm not going to explain it here...there are lots of other tuts on messagebox examples.)
  230.  
  231.  
  232. The last part of this crack is the -Unregistered bit.  So you can either look for that in the string references and go to it there or do it this way.  After the nag, the windowframe must be the next thing made so it should be soon after that last good_guy jump we just patched.  Lets take a look.
  233.  
  234. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  235. |:0040D34B(C)
  236. |
  237. :0040D387 8D442418                lea eax, dword ptr [esp+18]
  238. :0040D38B 8BCE                    mov ecx, esi
  239. :0040D38D 50                      push eax
  240. :0040D38E E8815F0400              call 00453314
  241. :0040D393 8D4C2420                lea ecx, dword ptr [esp+20]
  242. :0040D397 E80F940400              call 004567AB
  243. :0040D39C B30B                    mov bl, 0B
  244.  
  245. * Possible Reference to String Resource ID=02173: " -  Unregistered"
  246.                                   |
  247. :0040D39E 687D080000              push 0000087D
  248. :0040D3A3 8D4C2424                lea ecx, dword ptr [esp+24]
  249. :0040D3A7 885C2478                mov byte ptr [esp+78], bl
  250. :0040D3AB E8A79A0400              call 00456E57
  251.  
  252.  
  253. Yep, this looks good.  All we have to do is fix that 'push' at line 0040D39E.  Remember Intel processors handle information a bit strange, its all in reverse so the first byte of the 
  254.  0000087d thats being pushed will be the last in the opcode.  So, remembering that, and remembering that '68' is the opcode for 'push' we can change;
  255.  
  256. 687d080000   push 0000087d  (push the -Unregistered sign)
  257.  
  258. TO
  259.  
  260. 6800000000   push 00000000  (push absolutly nothing!)
  261.  
  262. Do these patches like you did the first one in your hexeditor and enjoy the program.  These are the only limitations of the program I know of but if you find any others, or have any suggestions or comments (criticisms) on this (please remember im still a newbie :) find me on #cracking4newbies on IRC (Efnet).